#ifndef SENSORTRAYMAP_H
#define SENSORTRAYMAP_H

#include "sensortraymaterialdata.h"
#include "traymap.h"
#include <QObject>

class SensorTrayMap : public TrayMap
{
    Q_OBJECT
public:
    explicit SensorTrayMap(TrayConfig *trayConfig, QString trayMapName, QString materialDataStoreFileName)
        : TrayMap(trayConfig, trayMapName, materialDataStoreFileName, &SensorTrayMaterialData::staticMetaObject)
    {
    }

    SensorTrayMaterialData *getPrOkData(int columnIndex, SensorTrayMaterialData::DispenseHead handledByWhichDH)
    {
        for (int i = 0; i < trayConfig->rows(); i++)
        {
            auto data = getData<SensorTrayMaterialData>(i, columnIndex);
            if (data->materialState() == SensorTrayMaterialData::DispPrOk
                && data->willBeHandledByWhichDH() == handledByWhichDH)
            {
                return data;
            }
        }
        return nullptr;
    }

    SensorTrayMaterialData *getDispOkData(int columnIndex)
    {
        for (int i = 0; i < trayConfig->rows(); i++)
        {
            auto data = getData<SensorTrayMaterialData>(i, columnIndex);
            if (data->materialState() == SensorTrayMaterialData::DispenseOk)
            {
                return data;
            }
        }
        return nullptr;
    }
};

#endif    // SENSORTRAYMAP_H
